/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package pe.edu.pucp.sigepa.recocidosimulado.Modelo;

import java.io.Serializable;
import java.util.Date;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author carloslengua
 */
@Entity
@Table(name = "avion")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Avion.findAll", query = "SELECT a FROM Avion a"),
    @NamedQuery(name = "Avion.findByIdavion", query = "SELECT a FROM Avion a WHERE a.idavion = :idavion"),
    @NamedQuery(name = "Avion.findByFechareg", query = "SELECT a FROM Avion a WHERE a.fechareg = :fechareg")})
public class Avion implements Serializable {
//    @OneToMany(cascade = CascadeType.ALL, mappedBy = "avion", fetch = FetchType.LAZY)
//    private List<VueloSim> vueloSimList;
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "idavion")
    private Integer idavion;
    @Basic(optional = false)
    @Column(name = "fechareg")
    @Temporal(TemporalType.TIMESTAMP)
    private Date fechareg;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "avion", fetch = FetchType.LAZY)
    private List<Vuelo> vueloList;
    @JoinColumn(name = "idtipo", referencedColumnName = "idtipo")
    @ManyToOne(optional = false, fetch = FetchType.LAZY)
    private TipoAvion tipoAvion;
    @JoinColumn(name = "idestado", referencedColumnName = "idestado")
    @ManyToOne(optional = false, fetch = FetchType.LAZY)
    private EstadoAvion estadoAvion;

    public Avion() {
    }

    public Avion(Integer idavion) {
        this.idavion = idavion;
    }

    public Avion(Integer idavion, Date fechareg) {
        this.idavion = idavion;
        this.fechareg = fechareg;
    }

    public Integer getIdavion() {
        return idavion;
    }

    public void setIdavion(Integer idavion) {
        this.idavion = idavion;
    }

    public Date getFechareg() {
        return fechareg;
    }

    public void setFechareg(Date fechareg) {
        this.fechareg = fechareg;
    }

    @XmlTransient
    public List<Vuelo> getVueloList() {
        return vueloList;
    }

    public void setVueloList(List<Vuelo> vueloList) {
        this.vueloList = vueloList;
    }

    public TipoAvion getTipoAvion() {
        return tipoAvion;
    }

    public void setTipoAvion(TipoAvion tipoAvion) {
        this.tipoAvion = tipoAvion;
    }

    public EstadoAvion getEstadoAvion() {
        return estadoAvion;
    }

    public void setEstadoAvion(EstadoAvion estadoAvion) {
        this.estadoAvion = estadoAvion;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idavion != null ? idavion.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Avion)) {
            return false;
        }
        Avion other = (Avion) object;
        if ((this.idavion == null && other.idavion != null) || (this.idavion != null && !this.idavion.equals(other.idavion))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "pe.edu.pucp.sigepa.recocidosimulado.Modelo.Avion[ idavion=" + idavion + " ]";
    }

//    @XmlTransient
//    public List<VueloSim> getVueloSimList() {
//        return vueloSimList;
//    }
//
//    public void setVueloSimList(List<VueloSim> vueloSimList) {
//        this.vueloSimList = vueloSimList;
//    }
    
}
